/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tools.packet;

import client.MapleBuffStat;
import client.MapleBuffStatValueHolder;
import client.MapleCharacter;
import client.MapleDisease;
import constants.GameConstants;
import constants.JobConstants;
import constants.SkillConstants;
import constants.skills.*;
import handling.Buffstat;
import handling.opcode.SendPacketOpcode;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.NotNull;
import server.MapleStatEffect;
import server.MapleStatEffectFactory;
import server.maps.MapleArrowsTurret;
import tools.MaplePacketCreator;
import tools.Randomizer;
import tools.data.output.MaplePacketLittleEndianWriter;

import java.awt.*;
import java.util.*;
import java.util.List;

/**
 * @author PlayDK
 */
public class BuffPacket {

    /**
     * Logger for this class.
     */
    private static final Logger log = LogManager.getLogger(BuffPacket.class);

    public static byte[] giveBuff(Map<MapleBuffStat, Integer> statups, MapleStatEffect effect, MapleCharacter chr) {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.GIVE_BUFF.getValue());
        boolean isWriteIntValue = false;
        EnumMap<MapleBuffStat, MapleBuffStatValueHolder> statupmbsvhs = new EnumMap<>(MapleBuffStat.class);
        EnumMap<MapleBuffStat, Integer> enummap2 = new EnumMap<>(MapleBuffStat.class);
        for (Map.Entry<MapleBuffStat, Integer> entry : statups.entrySet()) {
            MapleBuffStatValueHolder mbsvh = chr.getBuffStatValueHolder(entry.getKey(), Math.abs(entry.getValue()));
            if (mbsvh != null) {
                statupmbsvhs.put(entry.getKey(), mbsvh);
                enummap2.put(entry.getKey(), mbsvh.getValue());
                if (SkillConstants.isWriteBuffIntValue(entry.getKey())) {
                    isWriteIntValue = true;
                }
            }
        }
        writeBuffMask(mplew, statupmbsvhs.keySet());
        for (Map.Entry<MapleBuffStat, MapleBuffStatValueHolder> entry : statupmbsvhs.entrySet()) {
            if (!entry.getKey().canStack()) {
                MapleBuffStatValueHolder mbsvh = entry.getValue();
                int value = entry.getKey() == MapleBuffStat.MobZoneState ? 1 : mbsvh.getValue();
                if (isWriteIntValue) {
                    mplew.writeInt(value);
                } else {
                    mplew.writeShort(value);
                }
                mplew.writeInt(mbsvh.getEffect().isSkill() ? mbsvh.getEffectID() : -mbsvh.getEffectID());
                int n4 = mbsvh.getBuffLength();
                mplew.writeInt(n4 == 2100000000 ? 0 : n4);
            }
        }
        for (Map.Entry<MapleBuffStat, MapleBuffStatValueHolder> entry : statupmbsvhs.entrySet()) {
            if (SkillConstants.f(entry.getKey()) && !entry.getKey().canStack()) {
                MapleBuffStatValueHolder mbsvh = entry.getValue();
                if (isWriteIntValue) {
                    mplew.writeInt(mbsvh.getValue());
                } else {
                    mplew.writeShort(mbsvh.getValue());
                }
                mplew.writeInt(mbsvh.getEffect().isSkill() ? mbsvh.getEffectID() : -mbsvh.getEffectID());
                mplew.writeInt(mbsvh.getBuffLength());
            }
        }
        // 没有特殊数据的话跳过 9byte
        writeBuffData(mplew, enummap2, effect, chr);
        for (Map.Entry<MapleBuffStat, MapleBuffStatValueHolder> entry : statupmbsvhs.entrySet()) {
            if (entry.getKey().canStack() && SkillConstants.isWriteNeedPointValue(entry.getKey())) {
                MapleBuffStatValueHolder mbsvh = entry.getValue();
                mplew.writeInt(mbsvh.getValue());
                mplew.writeInt(mbsvh.getEffect().isSkill() ? mbsvh.getEffectID() : -mbsvh.getEffectID());
                mplew.write(entry.getKey() == MapleBuffStat.极速领域 ? 1 : 0);
                mplew.writeInt(entry.getKey() == MapleBuffStat.极速领域 ? 2 : 0);
                switch (entry.getKey()) {
                    case 极速领域:
                        mplew.write(1);
                        mplew.writeInt(2);
                        mplew.writeShort(mbsvh.getLocalDuration() / 1000);
                        continue;
                    case RideVehicleExpire:
                        mplew.writeShort(10);
                        continue;
//                    case 导航辅助:
//                        mplew.writeInt(chr.getLinkMobObjectID());
//                        mplew.writeInt(0);
//                        continue;
                }
            }
        }
        for (Map.Entry<MapleBuffStat, Integer> entry : statups.entrySet()) {
            if (entry.getKey().canStack() && !SkillConstants.isWriteNeedPointValue(entry.getKey())) {
                List<MapleBuffStatValueHolder> specialBuffInfo = chr.getIndieBuffStatValueHolder(entry.getKey());
                mplew.writeInt(specialBuffInfo.size());
                specialBuffInfo.forEach(mbsvh -> {
                    mplew.writeInt(mbsvh.getEffect().isSkill() ? mbsvh.getEffectID() : -mbsvh.getEffectID());
                    mplew.writeInt(mbsvh.getValue());
                    mplew.writeIntAsLong(mbsvh.getStartTime());
                    mplew.writeIntAsLong(mbsvh.getEndTime());
                    mplew.writeInt(mbsvh.getLocalDuration() == 2100000000 ? 0 : mbsvh.getLocalDuration());
                    mplew.writeInt(0);
                });
            }
        }
        if (statups.containsKey(MapleBuffStat.隐身术)) {
            // empty if block
        }
        if (statups.containsKey(MapleBuffStat.UNK_MBS_456)) {
            mplew.writeInt(0);
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.UNK499)) {
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.荣耀之翼)) {
            mplew.writeInt(chr.getBuffedIntZ(MapleBuffStat.荣耀之翼));
            mplew.writeInt(chr.getBuffedIntZ(MapleBuffStat.荣耀之翼));
        }
        if (statups.containsKey(MapleBuffStat.祝福标记)) {
            mplew.writeInt(0);
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.飞行骑乘)) {
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.UNK560)) {
            mplew.write(0);
        }
        if (statups.containsKey(MapleBuffStat.ReduceMana)) {
            mplew.writeInt(0);
            mplew.writeInt(0);
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.UNK562)) {
            mplew.writeInt(0);
            mplew.writeInt(0);
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.UNK563)) {
            mplew.writeInt(0);
            mplew.writeInt(0);
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.UNK500)) {
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.UNK564)) {
            mplew.writeInt(0);
            mplew.writeInt(0);
            mplew.writeInt(0);
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.UNK565)) {
            mplew.writeInt(0);
            mplew.writeInt(0);
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.武器多样化)) {
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.过载模式)) {
            mplew.writeInt(0);
        }
        mplew.writeShort(0);
        mplew.write(0);
        mplew.write(0);
        mplew.write(1);
        for (Map.Entry<MapleBuffStat, Integer> entry : statups.entrySet()) {
            if (SkillConstants.isWriteBuffByteData(entry.getKey())) {
                mplew.write(0);
            }
        }
        mplew.writeInt(0);
        return mplew.getPacket();
    }

    @NotNull
    public static byte[] giveSingleBuff(int buffid, int bufflength, Map<MapleBuffStat, Integer> statups, MapleStatEffect effect, MapleCharacter chr) {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
        mplew.writeShort(SendPacketOpcode.GIVE_BUFF.getValue());
        writeBuffMask(mplew, statups);
        boolean isWriteInt = statups.entrySet().stream().anyMatch(entry -> SkillConstants.isWriteBuffIntValue(entry.getKey()));
        for (Map.Entry<MapleBuffStat, Integer> entry : statups.entrySet()) {
            int value = entry.getKey() == MapleBuffStat.MobZoneState ? 1 : entry.getValue();
            if (isWriteInt) {
                mplew.writeInt(value);
            } else {
                mplew.writeShort(value);
            }
            mplew.writeInt(buffid);
            mplew.writeInt(bufflength == 2100000000 ? 0 : bufflength);
        }
        writeBuffData(mplew, statups, effect, chr);
        mplew.writeZeroBytes(9);
        return mplew.getPacket();
    }

    /**
     * 幸运骰子BUFF
     *
     * @param buffid
     * @param skillid
     * @param duration
     * @param statups
     * @return
     */
    public static byte[] giveDice(int buffid, int skillid, int duration, Map<MapleBuffStat, Integer> statups, MapleCharacter player) {
        log.trace("调用");
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.GIVE_BUFF.getValue());
        writeBuffMask(mplew, statups);
        //Math.max(buffid / 100, Math.max(buffid / 10, buffid % 10))
        int dice = buffid >= 100 ? buffid / 100 : buffid;
        mplew.writeShort(dice); // 普通为 1-6 双幸运为 10 - 100

        mplew.writeInt(skillid); // 技能ID
        mplew.writeInt(duration);// 持续时间
        mplew.writeZeroBytes(9); // T071修改 以前为3

        mplew.writeInt(GameConstants.getDiceStat(dice, 3)); //0x14
        mplew.writeInt(GameConstants.getDiceStat(dice, 3)); //0x14
        mplew.writeInt(GameConstants.getDiceStat(dice, 4)); //0x0F
        mplew.writeZeroBytes(20); //idk
        mplew.writeInt(GameConstants.getDiceStat(dice, 2)); //0x1E
        mplew.writeZeroBytes(12); //idk
        mplew.writeInt(GameConstants.getDiceStat(dice, 5)); //0x14
        mplew.writeZeroBytes(16); //idk
        mplew.writeInt(GameConstants.getDiceStat(dice, 6)); //0x1E
        mplew.writeZeroBytes(16);
        int energy = 0;
        if (player.getSpecialStat().isEnergyFull()) {
            energy = player.getStatForBuff(MapleBuffStat.能量获得).getSourceid();
        }
        mplew.writeInt(energy);
        mplew.writeInt(1000);
        mplew.write(1);
        mplew.writeInt(0);

        return mplew.getPacket();
    }

    /**
     * 角色获得 疾驰 或者 极速领域 BUFF
     *
     * @param statups
     * @param duration
     * @param skillid
     * @return
     */
    public static byte[] givePirateBuff(Map<MapleBuffStat, Integer> statups, int duration, int skillid) {
        boolean infusion = skillid == 冲锋队长.极速领域 || skillid == 奇袭者.极速领域_新 || skillid % 10000 == 8006;
        log.trace("调用");
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.GIVE_BUFF.getValue());
        writeBuffMask(mplew, statups);
        mplew.writeZeroBytes(13); //V.114修改
        statups.forEach((left, right) -> {
            mplew.writeInt(right);
            mplew.writeLong(skillid);
            mplew.writeZeroBytes(infusion ? 6 : 1);
            mplew.writeShort(duration);
        });
        mplew.writeInt(infusion ? 600 : 0);
        mplew.write(1);
        if (!infusion) {
            mplew.write(4);
        }
        mplew.writeInt(0);

        return mplew.getPacket();
    }

    /*
     * 角色给怪物上 导航辅助 BUFF
     */
    public static byte[] give导航辅助(int skillid, int mobid, int x) {
        log.trace("调用");
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.GIVE_BUFF.getValue());
        writeBuffMask(mplew, Collections.singletonList(MapleBuffStat.导航辅助));
        mplew.writeZeroBytes(13); //V.114修改
        mplew.writeInt(x);
        mplew.writeInt(skillid);
        mplew.writeZeroBytes(5);
        mplew.writeInt(mobid);
        mplew.writeInt(0);
        mplew.writeInt(720); //[D0 02 00 00]
        mplew.writeZeroBytes(5);

        return mplew.getPacket();
    }

    /*
     * 角色自己看到能量获得BUFF
     */
    public static byte[] giveEnergyCharge(int bar, int buffId, boolean fullbar, boolean consume) {
        log.trace("调用");
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.GIVE_BUFF.getValue());
        writeBuffMask(mplew, Collections.singletonList(MapleBuffStat.能量获得));
        mplew.writeZeroBytes(9);
        mplew.writeInt(fullbar || (consume && bar > 0) ? buffId : 0); //满能量和消耗能量 写技能ID
        mplew.writeInt(Math.min(bar, 10000)); // 0 = 没有能量, 10000 = 满能量
        mplew.writeInt(0);
        mplew.writeInt(0); //[01 01 00 00] 当技能为3转且满能量 这个地方是这个
        mplew.writeZeroBytes(6);
        mplew.write(0x01); //这个地方是随机数字
        mplew.writeInt(0);

        return mplew.getPacket();
    }

    /*
     * 其他玩家看到角色自己看到能量获得BUFF
     */
    public static byte[] showEnergyCharge(int chrId, int bar, int buffId, boolean fullbar, boolean consume) {
        log.trace("调用");
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.GIVE_FOREIGN_BUFF.getValue());
        mplew.writeInt(chrId);
        writeBuffMask(mplew, Collections.singletonList(MapleBuffStat.能量获得));
        mplew.writeZeroBytes(23);
        mplew.writeInt(fullbar || (consume && bar > 0) ? buffId : 0); //满能量和消耗能量 写技能ID
        mplew.writeInt(Math.min(bar, 10000)); // 0 = 没有能量, 10000 = 满能量
        mplew.writeZeroBytes(11); //V.114.1 修改 没有持续时间
        mplew.write(0);

        return mplew.getPacket();
    }

    /*
     * 更新夜光当前界面的光暗点数
     */
    public static byte[] updateLuminousGauge(int points, byte type) {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.LUMINOUS_COMBO.getValue());
        mplew.writeInt(points);
        mplew.write(type);

        return mplew.getPacket();
    }

    /*
     * 是否开启尖兵能量
     */
    public static byte[] startPower() {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.GIVE_BUFF.getValue());
        writeBuffMask(mplew, Collections.singletonList(MapleBuffStat.尖兵能量));
        mplew.writeShort(1);
        mplew.writeInt(1);
        mplew.writeZeroBytes(13);
        mplew.writeInt(3);
        mplew.writeZeroBytes(12);

        return mplew.getPacket();
    }

    /*
     * 尖兵能量
     */
    public static byte[] updatePowerCount(int skillId, int count) {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.GIVE_BUFF.getValue());
        writeBuffMask(mplew, Collections.singletonList(MapleBuffStat.尖兵能量));
        mplew.writeShort(count);
        mplew.writeInt(skillId);
        mplew.writeZeroBytes(26); //V.114修改 以前 14

        return mplew.getPacket();
    }

    public static byte[] give狂龙变形值(int bar) {
        log.trace("调用");
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.GIVE_BUFF.getValue());
        writeBuffMask(mplew, Collections.singletonList(MapleBuffStat.变形值));
        mplew.writeInt(Math.min(bar, 700)); // 0 = no bar, 1000 = full bar
        mplew.writeShort(0);
//        mplew.write(HexTool.getByteArrayFromHexString("78 90 2A EC"));
        mplew.writeInt((int) PacketHelper.getTime(System.currentTimeMillis()));
        mplew.writeZeroBytes(5); //V.114修改
        mplew.writeInt(bar >= 700 ? 3 : bar >= 300 ? 2 : bar >= 100 ? 1 : 0);
        mplew.writeZeroBytes(17); //V.114修改 以前 9

        return mplew.getPacket();
    }

    public static byte[] show狂龙变形值(int chrId, int bar) {
        log.trace("调用");
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.GIVE_FOREIGN_BUFF.getValue());
        mplew.writeInt(chrId);
        writeBuffMask(mplew, Collections.singletonList(MapleBuffStat.变形值));
        mplew.writeInt(Math.min(bar, 1000));
        mplew.writeZeroBytes(31);
        mplew.write(0);

        return mplew.getPacket();
    }

    public static byte[] showPP(int pp, int job) {
        log.trace("调用");
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.GIVE_BUFF.getValue());
        writeBuffMask(mplew, Collections.singletonList(MapleBuffStat.心魂值));
        mplew.writeShort(pp);
        mplew.writeInt(job);
        mplew.writeZeroBytes(26);

        return mplew.getPacket();
    }

    /*
     * 狂龙战士 - 剑刃之壁
     */
    public static byte[] give剑刃之壁(int buffid, int bufflength, Map<MapleBuffStat, Integer> statups, int Event2emId, int type) {
        log.trace("调用");
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.GIVE_BUFF.getValue());
        writeBuffMask(mplew, statups);
        statups.forEach((left, right) -> {
            mplew.writeShort(right);
            mplew.writeInt(buffid);
            mplew.writeInt(bufflength);
        });
        boolean isNormal = buffid == 狂龙战士.剑刃之壁 || buffid == 狂龙战士.剑刃之壁_变身;
        mplew.writeZeroBytes(9);
        mplew.writeInt(type); //x ?
        mplew.writeInt(isNormal ? 3 : 5); //bulletCount ?
        mplew.writeInt(Event2emId);
        mplew.writeInt(isNormal ? 3 : 5); //mobCount ?
        mplew.writeZeroBytes(isNormal ? 16 : 24);
        mplew.writeInt(0);
        mplew.write(0x01);
        mplew.writeInt(0);

        return mplew.getPacket();
    }

    public static byte[] show剑刃之壁(int chrId, int buffid, Map<MapleBuffStat, Integer> statups, int Event2emId, int type) {
        log.trace("调用");
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.GIVE_FOREIGN_BUFF.getValue());
        mplew.writeInt(chrId);
        writeBuffMask(mplew, statups);
        statups.forEach((left, right) -> {
            mplew.writeShort(right);
            mplew.writeInt(buffid);
        });
        boolean isNormal = buffid == 狂龙战士.剑刃之壁 || buffid == 狂龙战士.剑刃之壁_变身;
        mplew.writeZeroBytes(7);
        mplew.writeInt(type);
        mplew.writeInt(isNormal ? 3 : 5);
        mplew.writeInt(Event2emId);
        mplew.writeInt(isNormal ? 3 : 5);
        mplew.writeZeroBytes(isNormal ? 22 : 26); //进阶的多4个00
        mplew.write(0);

        return mplew.getPacket();
    }

    public static byte[] giveSoulGauge(int count, int skillid) {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.GIVE_BUFF.getValue());
        writeBuffMask(mplew, Collections.singletonList(MapleBuffStat.SoulMP));
        mplew.writeShort(count);
        mplew.writeInt(skillid);//skill
        mplew.writeInt(Integer.MAX_VALUE);
        mplew.writeInt(1000);
        mplew.writeInt(skillid);//soulskill
        mplew.writeZeroBytes(22);

        return mplew.getPacket();
    }

    public static byte[] cancelSoulGauge() {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.CANCEL_BUFF.getValue());
        writeBuffMask(mplew, Collections.singletonList(MapleBuffStat.SoulMP));
        mplew.writeInt(0);

        return mplew.getPacket();
    }

    public static byte[] giveSoulEffect(int skillid) {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.GIVE_BUFF.getValue());
        writeBuffMask(mplew, Collections.singletonList(MapleBuffStat.FullSoulMP));
        mplew.writeShort(0);
        mplew.writeInt(skillid);
        mplew.writeInt(640000);
        mplew.writeLong(0);
        mplew.writeShort(8);
        mplew.writeLong(0);
        mplew.writeInt(0);
        mplew.writeInt(0);

        return mplew.getPacket();
    }

    public static byte[] giveForeignSoulEffect(int cid, int skillid) {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.GIVE_FOREIGN_BUFF.getValue());
        mplew.writeInt(cid);
        writeBuffMask(mplew, Collections.singletonList(MapleBuffStat.FullSoulMP));
        mplew.writeInt(skillid);
        mplew.writeLong(0x60000000000L);
        mplew.writeLong(0);
        mplew.writeLong(0);
        mplew.writeInt(0);
        mplew.writeInt(0);
        mplew.write(0);
        mplew.write(0);

        return mplew.getPacket();
    }

    public static byte[] cancelForeignSoulEffect(MapleCharacter player) {
        return cancelForeignBuff(player, Collections.singletonList(MapleBuffStat.FullSoulMP));
    }

    public static byte[] show灵魂武器(int buffid, int point) {

        log.trace("调用");
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.GIVE_BUFF.getValue());

        Map<MapleBuffStat, Integer> statups = new EnumMap<>(MapleBuffStat.class);
        statups.put(MapleBuffStat.SoulMP, 0);
        if (buffid > 0) {
            statups.put(MapleBuffStat.增加魔法攻击力, 0);
            statups.put(MapleBuffStat.增加物理攻击力, 0);
        }
        writeBuffMask(mplew, statups);
        mplew.writeShort(point);
        mplew.writeLong(buffid);
        mplew.writeShort(1000);
        mplew.writeShort(0);
        mplew.writeLong(buffid);
        mplew.writeShort(0);
        mplew.writeZeroBytes(3);

        if (buffid > 0) {
            for (int i = 0; i < 2; i++) {
                mplew.writeInt(1);
                mplew.writeInt(2590000);
                mplew.writeZeroBytes(13);
                mplew.writeHexString("75 2B 7D");
            }
        }

        mplew.writeHexString("00 00 00 00 01 00 00 00 00");
        mplew.writeInt(0);

        return mplew.getPacket();
    }

    public static byte[] show灵魂技能(int buffid) {

        log.trace("调用");
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.GIVE_BUFF.getValue());

        writeBuffMask(mplew, Collections.singletonList(MapleBuffStat.FullSoulMP));
        mplew.writeShort(0);
        mplew.writeInt(buffid);
        mplew.write(0);
        mplew.writeShort(2500);
        mplew.writeZeroBytes(27);

        return mplew.getPacket();
    }

    public static byte[] show灵魂助力(int value, boolean bl2, boolean bl3) {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.GIVE_BUFF.getValue());
        writeBuffMask(mplew, Collections.singletonList(MapleBuffStat.灵魂助力));
        mplew.writeShort(1);
        mplew.writeInt(黑骑士.灵魂助力);
        mplew.writeInt(value);
        mplew.writeInt(0);
        mplew.write(bl3 ? 9 : 8);
        mplew.writeInt(bl3 ? 黑骑士.灵魂助力统治 : 黑骑士.灵魂助力);
        mplew.writeInt(bl2 ? 黑骑士.灵魂助力震惊 : 0);
        mplew.writeInt(0);
        mplew.writeInt(0);
        mplew.write(1);
        mplew.writeInt(0);
        mplew.writeInt(0);

        return mplew.getPacket();
    }

    /*
     * 减益buff,怪给角色
     */
    public static byte[] giveDebuff(MapleDisease statups, int x, int skillid, int level, int duration) {
        log.trace("调用");
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.GIVE_BUFF.getValue());
        writeBuffMask(mplew, Collections.singletonList(statups));

        mplew.writeShort(x);
        mplew.writeShort(skillid);
        mplew.writeShort(level);
        mplew.writeInt(duration);
        mplew.writeZeroBytes(4); //未知
        if (skillid == MapleDisease.缓慢.getDisease()) { //好像是减速的时候 这个地方多1个
            mplew.write(0); //不知道是等级还是固定的 0x02
        }
        mplew.writeZeroBytes(5);
        mplew.writeShort(0); //[84 03] Delay
        mplew.writeZeroBytes(3);
        if (skillid == MapleDisease.缓慢.getDisease()) {
            mplew.write(3);
        } else {
            mplew.write(4);
        }
        mplew.writeZeroBytes(9); //未知 V.112新增

        return mplew.getPacket();
    }

    public static void writeBuffData(MaplePacketLittleEndianWriter mplew, Map<MapleBuffStat, Integer> statups, MapleStatEffect effect, MapleCharacter player) {
        int n2;
        if (statups.containsKey(MapleBuffStat.SoulMP)) {
            mplew.writeInt(0);
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.FullSoulMP)) {
            mplew.writeInt(0);
        }
        mplew.writeShort(0);
        if (statups.containsKey(MapleBuffStat.拔刀姿势)) {
            mplew.writeInt(-剑豪.拔刀姿势);
        }
        mplew.write(0);
        mplew.write(0);
        mplew.write(0);
        mplew.writeInt((effect != null && effect.getSourceid() == 400021060) ? 16769792 : 0);
        if (statups.containsKey(MapleBuffStat.幸运骰子)) {
            for (n2 = 0; n2 < 22; ++n2) {
                mplew.writeInt(0);
            }
        }
        if (statups.containsKey(MapleBuffStat.KeyDownMoving)) {
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.UNK542)) {
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.击杀点数)) {
            mplew.write(statups.get(MapleBuffStat.击杀点数));
        }
        if (statups.containsKey(MapleBuffStat.PinkbeanRollingGrade)) {
            mplew.write(0);
        }
        if (statups.containsKey(MapleBuffStat.卡牌审判)) {
            switch (statups.get(MapleBuffStat.卡牌审判)) {
                case 1:
                case 2:
                case 4: {
                    mplew.writeInt(effect.getSourceid() == 幻影.卡牌审判 ? 10 : 20);
                    break;
                }
                case 3: {
                    mplew.writeInt(2020);
                    break;
                }
                default: {
                    mplew.writeInt(0);
                }
            }
        }
        if (statups.containsKey(MapleBuffStat.黑暗高潮)) {
            mplew.write(player.getBuffedIntZ(MapleBuffStat.黑暗高潮));
        }
        if (statups.containsKey(MapleBuffStat.三位一体)) {
            mplew.write(statups.get(MapleBuffStat.三位一体) / 5);
        }
        if (statups.containsKey(MapleBuffStat.元素冲击)) {
            int value = statups.get(MapleBuffStat.元素冲击) / effect.getX();
            mplew.write(value);
            mplew.writeShort(effect.getY() * value);
            mplew.write(value * 2);
            mplew.write(value * 2);
        }
        if (statups.containsKey(MapleBuffStat.生命潮汐)) {
            n2 = 0;
            switch (statups.get(MapleBuffStat.生命潮汐)) {
                case 1: {
                    n2 = effect.getX();
                    break;
                }
                case 2: {
                    n2 = effect.getProp();
                    break;
                }
                case 3: {
                    n2 = player.getStat().getHp();
                }
            }
            mplew.writeInt(n2);
        }
        if (statups.containsKey(MapleBuffStat.神圣保护)) {
            n2 = statups.get(MapleBuffStat.神圣保护) == 2 && player.getBuffSource(MapleBuffStat.神圣保护) == 2311012 ? 1 : 0;
            mplew.write(n2);
        }
        if (statups.containsKey(MapleBuffStat.光暗转换)) {
            n2 = statups.get(MapleBuffStat.光暗转换);
            mplew.writeInt(n2 == 1 ? effect.getSourceid() : 夜光.月蚀);
            mplew.writeInt(effect.getDuration());
            mplew.writeInt(n2 == 1 ? 0 : 夜光.太阳火焰);
            mplew.writeInt(n2 == 1 ? 0 : effect.getDuration());
            mplew.writeInt(-1);
            mplew.writeInt(player.getSpecialStat().getDarkLight());
            mplew.writeInt(0); //n2 == 2 && player.getenattacke() ? 1 : 0
        }
        if (statups.containsKey(MapleBuffStat.百分比无视防御)) {
            mplew.writeInt(player.getBuffedIntZ(MapleBuffStat.百分比无视防御));
        }
        if (statups.containsKey(MapleBuffStat.剑刃之壁)) {
            PacketHelper.write剑刃之壁(mplew, player, effect.getSourceid());
        }
        if (statups.containsKey(MapleBuffStat.变形值)) {
            n2 = 0;
            if (player.getMorphCount() >= 100) {
                n2 = 1;
            } else if (player.getMorphCount() >= 300) {
                n2 = 2;
            }
            mplew.writeInt(n2);
        }
        if (statups.containsKey(MapleBuffStat.MobZoneState)) {
            ArrayList<Object> arrayList = new ArrayList<>();
            arrayList.add(statups.get(MapleBuffStat.MobZoneState));
            arrayList.add(-1);
            for (Object anArrayList : arrayList) {
                int n4 = (Integer) anArrayList;
                mplew.writeInt(n4);
            }
        }
        if (statups.containsKey(MapleBuffStat.宝珠_伤害增加)) {
            mplew.writeInt(2);
            mplew.writeInt(152120001);
            mplew.writeInt(400021000);
        }
        if (statups.containsKey(MapleBuffStat.缓慢)) {
            mplew.write(0);
        }
        if (statups.containsKey(MapleBuffStat.寒冰灵气)) {
            mplew.write(1);
        }
        if (statups.containsKey(MapleBuffStat.抗震防御)) {
            mplew.write(1);
        }
        if (statups.containsKey(MapleBuffStat.IgnoreMobpdpR)) {
            mplew.write(0);
        }
        if (statups.containsKey(MapleBuffStat.BOSS伤害)) {
            mplew.write(1);
        }
        if (statups.containsKey(MapleBuffStat.DropRIncrease)) {
            mplew.writeInt(0);
            mplew.write(0);
        }
        if (statups.containsKey(MapleBuffStat.月光转换)) {
            mplew.write(player.getBuffedIntValue(MapleBuffStat.日月轮转));
        }
        if (statups.containsKey(MapleBuffStat.灵魂助力)) {
            //TODO 灵魂助力
//            final com.cms.launch.b.a buffStatValueHolder = o.getBuffStatValueHolder(MapleBuffStat.LA, 1301013);
//            b.writeInt((o.getSkillLevel(1310013) > 0) ? 1310013 : 0);
//            b.writeInt((buffStatValueHolder != null) ? buffStatValueHolder.ayx : 0);
            mplew.writeInt((player.getSkillLevel(1310013) > 0) ? 1310013 : 0);
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.交叉锁链)) {
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.重生契约)) {
            mplew.writeInt(player.getBuffedIntValue(MapleBuffStat.重生契约));
        }
        if (statups.containsKey(MapleBuffStat.极限射箭)) {
            mplew.writeInt(0);
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.三彩箭矢)) {
            mplew.writeInt(player.getBuffedIntZ(MapleBuffStat.三彩箭矢));
        }
        if (statups.containsKey(MapleBuffStat.ImmuneBarrier)) {
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.圣洁之力)) {
            mplew.write(0);
        }
        if (statups.containsKey(MapleBuffStat.神圣迅捷)) {
            mplew.write(0);
        }
        if (statups.containsKey(MapleBuffStat.防甲穿透)) {
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.火眼晶晶)) {
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.进阶祝福)) {
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.DebuffTolerance)) {
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.DotHealHPPerSecond)) {
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.招魂结界)) {
            mplew.writeInt(statups.get(MapleBuffStat.招魂结界));
        }
        if (statups.containsKey(MapleBuffStat.UNK404)) {
            mplew.writeInt(statups.get(MapleBuffStat.UNK404));
        }
        if (statups.containsKey(MapleBuffStat.KnockBack)) {
            mplew.writeInt(0);
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.灵魂吸取专家)) {
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.SSFShootingAttack)) {
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.战法灵气)) {
            mplew.writeInt(738263040);
            mplew.write(1);
        }
        if (statups.containsKey(MapleBuffStat.结合灵气)) {
            mplew.writeInt(1);
        }
        if (statups.containsKey(MapleBuffStat.PinkbeanAttackBuff)) {
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.皇家守护)) {
            mplew.writeInt(statups.get(MapleBuffStat.增加物理攻击力));
            mplew.writeInt(statups.get(MapleBuffStat.皇家守护));
        }
        if (statups.containsKey(MapleBuffStat.灵魂链接)) {
            mplew.writeInt(player.getBuffStatValueHolder(MapleBuffStat.灵魂链接).getCid() == player.getId() ? statups.get(MapleBuffStat.灵魂链接) : 0);
            mplew.writeBool(player.getParty() == null || player.getParty() != null && player.getParty().getMembers().size() == 1);
            mplew.writeInt(player.getBuffStatValueHolder(MapleBuffStat.灵魂链接).getCid());
            mplew.writeInt(player.getBuffStatValueHolder(MapleBuffStat.灵魂链接).getCid() != player.getId() ? (int) player.getBuffStatValueHolder(MapleBuffStat.灵魂链接).getEffect().getLevel() : 0);
        }
        if (statups.containsKey(MapleBuffStat.激素狂飙)) {
            mplew.write(effect.getSourceid() == 战神.激素狂飙 ? 1 : 0);
        }
        if (statups.containsKey(MapleBuffStat.爆破弹夹)) {
            mplew.write(player.getBullet());
            mplew.writeShort(player.getCylinder());
        }
        if (statups.containsKey(MapleBuffStat.钢铁之躯)) {
            mplew.writeInt(player.getBuffedIntZ(MapleBuffStat.钢铁之躯));
        }
        if (statups.containsKey(MapleBuffStat.UNK_MBS_450)) {
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.呼啸暴风)) {
            mplew.writeShort(0);
            mplew.write(0);
        }
        mplew.writeInt(player != null && player.getSpecialStat().isEnergyFull() ? player.getBuffSource(MapleBuffStat.能量获得) : 0);
        if (statups.containsKey(MapleBuffStat.不消耗HP)) {
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.隐身术)) {
            mplew.writeInt(660);
            mplew.writeInt(660);
        }
        if (statups.containsKey(MapleBuffStat.戴米安刻印)) {
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.精灵元素)) {
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.暴击蓄能)) {
            mplew.writeInt(player != null ? player.getBuffedIntZ(MapleBuffStat.暴击蓄能) : 0);
        }
        if (statups.containsKey(MapleBuffStat.引燃)) {
            mplew.writeInt(player != null ? player.getBuffedIntZ(MapleBuffStat.引燃) : 0);
        }
        if (statups.containsKey(MapleBuffStat.敛财术)) {
            mplew.writeInt(player != null ? player.getBuffedIntZ(MapleBuffStat.敛财术) : 0);
        }
        if (statups.containsKey(MapleBuffStat.神圣归一)) {
            mplew.writeShort(effect.getZ());
        }
        if (statups.containsKey(MapleBuffStat.恶魔狂怒)) {
            mplew.writeShort(player != null ? player.getBuffedValue(MapleBuffStat.恶魔狂怒) : 0);
        }
        if (statups.containsKey(MapleBuffStat.SpinesOfShadow)) {
            mplew.writeShort(35);
        }
        if (statups.containsKey(MapleBuffStat.神奇圆环)) {
            mplew.writeInt(0);
            mplew.writeInt(0);
            mplew.writeInt(0);
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.VampDeath)) {
            mplew.writeInt(3);
        }
    }

    /*
     * 其他玩家看到别人获得负面BUFF状态
     */
    public static byte[] giveForeignDebuff(int chrId, MapleDisease statups, int skillid, int level, int x) {
        log.trace("调用");
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.GIVE_FOREIGN_BUFF.getValue());
        mplew.writeInt(chrId);
        writeBuffMask(mplew, Collections.singletonList(statups));
        if (skillid == 125) { //中毒
            mplew.writeShort(0);
            mplew.write(0); //todo test
        }
        if (skillid == 184) {
            mplew.writeInt(x);
        } else {
            mplew.writeShort(x);
        }
        mplew.writeShort(skillid);
        mplew.writeShort(level);
        mplew.writeZeroBytes(27);
        mplew.writeShort(900); //Delay
        mplew.write(0);

        return mplew.getPacket();
    }

    /*
     * 其他玩家看到别人取消负面BUFF状态
     */
    public static byte[] cancelForeignDebuff(MapleCharacter player, MapleDisease mask) {
        log.trace("调用");
        return cancelForeignBuff(player, Collections.singletonList(mask.getBuffStat()));
    }

    /*
     * 其他玩家看到别人取消BUFF状态
     */
    public static byte[] cancelForeignBuff(MapleCharacter player, List<MapleBuffStat> statups) {
        log.trace("调用");
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.CANCEL_FOREIGN_BUFF.getValue());
        mplew.writeInt(player.getId());
        writeBuffMask(mplew, statups);
        boolean a2 = false;
        for (final MapleBuffStat p2 : statups) {
            if (!a2) {
                a2 = MapleDisease.isDisease(p2);
            }
            if (p2.canStack() && !SkillConstants.isWriteNeedPointValue(p2)) {
                final List<MapleBuffStatValueHolder> mbsvhs = player.getIndieBuffStatValueHolder(p2);
                mplew.writeInt((mbsvhs != null) ? mbsvhs.size() : 0);
                if (mbsvhs == null || mbsvhs.size() <= 0) {
                    continue;
                }
                for (final MapleBuffStatValueHolder mbsvh : mbsvhs) {
                    mplew.writeInt(mbsvh.getEffect().getSourceid());
                    mplew.writeInt(mbsvh.getValue());
                    mplew.writeIntAsLong(mbsvh.getStartTime());
                    mplew.writeInt(0);
                    mplew.writeInt(mbsvh.getLocalDuration());
                    mplew.writeInt(0);
                }
            }
        }
        if (statups.contains(MapleBuffStat.月光转换)) {
            mplew.write(1);
        }
        for (MapleBuffStat statup : statups) {
            if (SkillConstants.isWriteBuffByteData(statup)) {
                mplew.write(0);
            }
        }
        mplew.write(1);

        return mplew.getPacket();
    }

    public static byte[] giveForeignBuff(MapleCharacter player, Map<MapleBuffStat, Integer> statups, MapleStatEffect effect) {
        log.trace("调用");
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.GIVE_FOREIGN_BUFF.getValue());
        mplew.writeInt(player.getId());
        writeForeignBuff(mplew, player, statups, false);
        mplew.writeShort(0);
        mplew.write(0);

        return mplew.getPacket();
    }

    public static void writeForeginBuff(MaplePacketLittleEndianWriter mplew) {
        MapleStatEffectFactory.logname += "length=1";
    }

    public static void writeForeignBuff(MaplePacketLittleEndianWriter mplew, MapleCharacter player, Map<MapleBuffStat, Integer> statups, boolean isChrinfo) {
        int sourceid;
        int rand;
        writeBuffMask(mplew, statups);
        if (statups.containsKey(MapleBuffStat.移动速度)) {
            mplew.write(player.getBuffedIntValue(MapleBuffStat.移动速度));
        }
        if (statups.containsKey(MapleBuffStat.斗气集中)) {
            mplew.write(player.getBuffedIntValue(MapleBuffStat.斗气集中));
        }
        if (statups.containsKey(MapleBuffStat.祝福之锤)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.祝福之锤));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.祝福之锤));
        }
        if (statups.containsKey(MapleBuffStat.属性攻击)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.属性攻击));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.属性攻击));
        }
        if (statups.containsKey(MapleBuffStat.元素冲击)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.元素冲击));
        }
        if (statups.containsKey(MapleBuffStat.昏迷)) {
            mplew.writeShort(1);
            mplew.writeShort(player.getDiseasesValue(MapleDisease.昏迷).skillid);
            mplew.writeShort(player.getDiseasesValue(MapleDisease.昏迷).level);
        }
        if (statups.containsKey(MapleBuffStat.Shock)) {
            mplew.write(1);
        }
        if (statups.containsKey(MapleBuffStat.黑暗)) {
            mplew.writeShort(1);
            mplew.writeShort(player.getDiseasesValue(MapleDisease.黑暗).skillid);
            mplew.writeShort(player.getDiseasesValue(MapleDisease.黑暗).level);
        }
        if (statups.containsKey(MapleBuffStat.封印)) {
            mplew.writeShort(1);
            mplew.writeShort(player.getDiseasesValue(MapleDisease.封印).skillid);
            mplew.writeShort(player.getDiseasesValue(MapleDisease.封印).level);
        }
        if (statups.containsKey(MapleBuffStat.虚弱)) {
            mplew.writeShort(1);
            mplew.writeShort(player.getDiseasesValue(MapleDisease.虚弱).skillid);
            mplew.writeShort(player.getDiseasesValue(MapleDisease.虚弱).level);
        }
        if (statups.containsKey(MapleBuffStat.WeaknessMdamage)) {
            mplew.writeShort(0);
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.诅咒)) {
            mplew.writeShort(1);
            mplew.writeShort(player.getDiseasesValue(MapleDisease.诅咒).skillid);
            mplew.writeShort(player.getDiseasesValue(MapleDisease.诅咒).level);
        }
        if (statups.containsKey(MapleBuffStat.缓慢)) {
            mplew.writeShort(1);
            mplew.writeShort(player.getDiseasesValue(MapleDisease.缓慢).skillid);
            mplew.writeShort(player.getDiseasesValue(MapleDisease.缓慢).level);
        }
        if (statups.containsKey(MapleBuffStat.PvPRaceEffect)) {
            mplew.writeShort(0);
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.DisOrder)) {
            mplew.writeShort(0);
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.Explosion)) {
            mplew.write(0);
        }
        if (statups.containsKey(MapleBuffStat.Thread)) {
            mplew.writeShort(0);
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.Team)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.Team));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.Team));
        }
        if (statups.containsKey(MapleBuffStat.中毒)) {
            mplew.writeShort(1);
        }
        if (statups.containsKey(MapleBuffStat.中毒)) {
            mplew.writeShort(1);
            mplew.writeShort(player.getDiseasesValue(MapleDisease.中毒).skillid);
            mplew.writeShort(player.getDiseasesValue(MapleDisease.中毒).level);
        }
        if (statups.containsKey(MapleBuffStat.影分身)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.影分身));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.影分身));
        }
        if (statups.containsKey(MapleBuffStat.隐身术)) {
            // empty if block
        }
        if (statups.containsKey(MapleBuffStat.无形箭弩)) {
            // empty if block
        }
        if (statups.containsKey(MapleBuffStat.变身效果)) {
            mplew.writeShort(player.getStatForBuff(MapleBuffStat.变身效果).getMorph(player));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.变身效果));
        }
        if (statups.containsKey(MapleBuffStat.GHOST_MORPH)) {
            mplew.writeShort(0);
        }
        if (statups.containsKey(MapleBuffStat.诱惑)) {
            mplew.writeShort(1);
            mplew.writeShort(player.getDiseasesValue(MapleDisease.诱惑).skillid);
            mplew.writeShort(player.getDiseasesValue(MapleDisease.诱惑).level);
        }
        if (statups.containsKey(MapleBuffStat.Magnet)) {
            mplew.writeShort(0);
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.MagnetArea)) {
            mplew.writeShort(0);
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.暗器伤人)) {
            mplew.writeInt(player.getBuffedIntValue(MapleBuffStat.暗器伤人));
        }
        if (statups.containsKey(MapleBuffStat.不死化)) {
            mplew.writeShort(1);
            mplew.writeShort(player.getDiseasesValue(MapleDisease.不死化).skillid);
            mplew.writeShort(player.getDiseasesValue(MapleDisease.不死化).level);
        }
        if (statups.containsKey(MapleBuffStat.ARIANT_COSS_IMU)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.ARIANT_COSS_IMU));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.ARIANT_COSS_IMU));
        }
        if (statups.containsKey(MapleBuffStat.闪光击)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.闪光击));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.闪光击));
        }
        if (statups.containsKey(MapleBuffStat.混乱)) {
            mplew.writeShort(1);
            mplew.writeShort(player.getDiseasesValue(MapleDisease.混乱).skillid);
            mplew.writeShort(player.getDiseasesValue(MapleDisease.混乱).level);
        }
        if (statups.containsKey(MapleBuffStat.RespectPImmune)) {
            mplew.writeInt(player.getBuffedIntValue(MapleBuffStat.RespectPImmune));
        }
        if (statups.containsKey(MapleBuffStat.RespectMImmune)) {
            mplew.writeInt(player.getBuffedIntValue(MapleBuffStat.RespectMImmune));
        }
        if (statups.containsKey(MapleBuffStat.DefenseAtt)) {
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.ILLUSION)) {
            mplew.writeInt(player.getBuffedIntValue(MapleBuffStat.ILLUSION));
        }
        if (statups.containsKey(MapleBuffStat.狂暴战魂)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.狂暴战魂));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.狂暴战魂));
        }
        if (statups.containsKey(MapleBuffStat.金刚霸体)) {
            // empty if block
        }
        if (statups.containsKey(MapleBuffStat.天使状态)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.天使状态));
            mplew.writeInt(player.getTrueBuffSource(MapleBuffStat.天使状态));
        }
        if (statups.containsKey(MapleBuffStat.UNK545)) {
            mplew.writeShort(0);
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.无法使用药水)) {
            mplew.writeShort(1);
            mplew.writeShort(player.getDiseasesValue(MapleDisease.无法使用药水).skillid);
            mplew.writeShort(player.getDiseasesValue(MapleDisease.无法使用药水).level);
        }
        if (statups.containsKey(MapleBuffStat.SHADOW)) {
            mplew.writeShort(1);
            mplew.writeShort(player.getDiseasesValue(MapleDisease.SHADOW).skillid);
            mplew.writeShort(player.getDiseasesValue(MapleDisease.SHADOW).level);
        }
        if (statups.containsKey(MapleBuffStat.致盲)) {
            mplew.writeShort(1);
            mplew.writeShort(player.getDiseasesValue(MapleDisease.致盲).skillid);
            mplew.writeShort(player.getDiseasesValue(MapleDisease.致盲).level);
        }
        if (statups.containsKey(MapleBuffStat.魔法屏障)) {
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.飞翔)) {
            // empty if block
        }
        if (statups.containsKey(MapleBuffStat.FREEZE)) {
            mplew.writeShort(1);
            mplew.writeShort(player.getDiseasesValue(MapleDisease.FREEZE).skillid);
            mplew.writeShort(player.getDiseasesValue(MapleDisease.FREEZE).level);
        }
        if (statups.containsKey(MapleBuffStat.Frozen2)) {
            mplew.writeShort(0);
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.龙卷风)) {
            mplew.writeShort(1);
            mplew.writeShort(player.getDiseasesValue(MapleDisease.龙卷风).skillid);
            mplew.writeShort(player.getDiseasesValue(MapleDisease.龙卷风).level);
        }
        if (statups.containsKey(MapleBuffStat.撤步退身)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.撤步退身));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.撤步退身));
        }
        if (statups.containsKey(MapleBuffStat.终极斩)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.终极斩));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.终极斩));
        }
        if (statups.containsKey(MapleBuffStat.时间胶囊)) {
            mplew.write(0);
        }
        if (statups.containsKey(MapleBuffStat.潜入状态)) {
            // empty if block
        }
        if (statups.containsKey(MapleBuffStat.ATTACK_BUFF)) {
            // empty if block
        }
        if (statups.containsKey(MapleBuffStat.金属机甲)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.金属机甲));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.金属机甲));
        }
        if (statups.containsKey(MapleBuffStat.祝福护甲)) {
            // empty if block
        }
        if (statups.containsKey(MapleBuffStat.BlessingArmorIncPAD)) {
            // empty if block
        }
        if (statups.containsKey(MapleBuffStat.巨人药水)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.巨人药水));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.巨人药水));
        }
        if (statups.containsKey(MapleBuffStat.BuffLimit)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.BuffLimit));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.BuffLimit));
        }
        if (statups.containsKey(MapleBuffStat.DarkTornado)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.DarkTornado));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.DarkTornado));
        }
        if (statups.containsKey(MapleBuffStat.AmplifyDamage)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.AmplifyDamage));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.AmplifyDamage));
        }
        if (statups.containsKey(MapleBuffStat.风影漫步)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.风影漫步));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.风影漫步));
        }
        if (statups.containsKey(MapleBuffStat.神圣魔法盾)) {
            // empty if block
        }
        if (statups.containsKey(MapleBuffStat.黑暗变形)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.黑暗变形));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.黑暗变形));
        }
        if (statups.containsKey(MapleBuffStat.精神连接)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.精神连接));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.精神连接));
        }
        if (statups.containsKey(MapleBuffStat.神圣拯救者的祝福)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.神圣拯救者的祝福));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.神圣拯救者的祝福));
        }
        if (statups.containsKey(MapleBuffStat.Event2)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.Event2));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.Event2));
        }
        if (statups.containsKey(MapleBuffStat.DeathMark)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.DeathMark));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.DeathMark));
        }
        if (statups.containsKey(MapleBuffStat.PainMark)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.PainMark));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.PainMark));
        }
        if (statups.containsKey(MapleBuffStat.死亡束缚)) {
            mplew.writeShort(1);
            mplew.writeShort(player.getDiseasesValue(MapleDisease.死亡束缚).skillid);
            mplew.writeShort(player.getDiseasesValue(MapleDisease.死亡束缚).level);
        }
        if (statups.containsKey(MapleBuffStat.VampDeath)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.VampDeath));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.VampDeath));
        }
        if (statups.containsKey(MapleBuffStat.VampDeathSummon)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.VampDeathSummon));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.VampDeathSummon));
        }
        if (statups.containsKey(MapleBuffStat.VenomSnake)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.VenomSnake));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.VenomSnake));
        }
        // SPAWN 1
        if (statups.containsKey(MapleBuffStat.PyramidEffect)) {
            mplew.writeInt(-1);
        }
        // SPAWN 2
        if (statups.containsKey(MapleBuffStat.击杀点数)) {
            mplew.write(Math.min(player.getBuffedIntValue(MapleBuffStat.击杀点数), 5));
        }
        // SPAWN 8
        if (statups.containsKey(MapleBuffStat.PinkbeanRollingGrade)) {
            mplew.write(0);
        }
        if (statups.containsKey(MapleBuffStat.百分比无视防御)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.百分比无视防御));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.百分比无视防御));
        }
        if (statups.containsKey(MapleBuffStat.幻影屏障)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.幻影屏障));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.幻影屏障));
        }
        if (statups.containsKey(MapleBuffStat.卡牌审判)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.卡牌审判));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.卡牌审判));
        }
        if (statups.containsKey(MapleBuffStat.KeyDownAreaMoving)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.KeyDownAreaMoving));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.KeyDownAreaMoving));
        }
        if (statups.containsKey(MapleBuffStat.黑暗高潮)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.黑暗高潮));
        }
        if (statups.containsKey(MapleBuffStat.黑暗祝福)) {
            mplew.writeInt(player.getBuffedIntValue(MapleBuffStat.黑暗祝福));
        }
        if (statups.containsKey(MapleBuffStat.光暗转换)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.光暗转换));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.光暗转换));
        }
        if (statups.containsKey(MapleBuffStat.模式转换)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.模式转换));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.模式转换));
        }
        if (statups.containsKey(MapleBuffStat.SpecialAction)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.SpecialAction));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.SpecialAction));
        }
        if (statups.containsKey(MapleBuffStat.剑刃之壁)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.剑刃之壁));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.剑刃之壁));
        }
        if (statups.containsKey(MapleBuffStat.灵魂凝视)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.灵魂凝视));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.灵魂凝视));
        }
        if (statups.containsKey(MapleBuffStat.伤害置换)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.伤害置换));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.伤害置换));
        }
        if (statups.containsKey(MapleBuffStat.攻势之盾)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.攻势之盾));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.攻势之盾));
        }
        if (statups.containsKey(MapleBuffStat.天使亲和)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.天使亲和));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.天使亲和));
        }
        if (statups.containsKey(MapleBuffStat.灵魂鼓舞)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.灵魂鼓舞));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.灵魂鼓舞));
        }
        if (statups.containsKey(MapleBuffStat.隐藏碎片)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.隐藏碎片));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.隐藏碎片));
        }
        if (statups.containsKey(MapleBuffStat.变形值)) {
            mplew.writeShort(player.getMorphCount());
            mplew.writeInt(player.getBuffSource(MapleBuffStat.变形值));
        }
        if (statups.containsKey(MapleBuffStat.MobZoneState)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.MobZoneState));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.MobZoneState));
        }
        if (statups.containsKey(MapleBuffStat.GiveMeHeal)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.GiveMeHeal));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.GiveMeHeal));
        }
        if (statups.containsKey(MapleBuffStat.TouchMe)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.TouchMe));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.TouchMe));
        }
        if (statups.containsKey(MapleBuffStat.Contagion)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.Contagion));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.Contagion));
        }
        if (statups.containsKey(MapleBuffStat.Contagion)) {
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.连击无限制)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.连击无限制));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.连击无限制));
        }
        if (statups.containsKey(MapleBuffStat.至圣领域)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.至圣领域));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.至圣领域));
        }
        if (statups.containsKey(MapleBuffStat.IgnoreAllCounter)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.IgnoreAllCounter));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.IgnoreAllCounter));
        }
        if (statups.containsKey(MapleBuffStat.IgnorePImmune)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.IgnorePImmune));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.IgnorePImmune));
        }
        if (statups.containsKey(MapleBuffStat.IgnoreAllImmune)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.IgnoreAllImmune));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.IgnoreAllImmune));
        }
        if (statups.containsKey(MapleBuffStat.UNK280)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.UNK280));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.UNK280));
        }
        if (statups.containsKey(MapleBuffStat.最终审判)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.最终审判));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.最终审判));
        }
        if (statups.containsKey(MapleBuffStat.抗震防御)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.抗震防御));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.抗震防御));
        }
        if (statups.containsKey(MapleBuffStat.寒冰灵气)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.寒冰灵气));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.寒冰灵气));
        }
        if (statups.containsKey(MapleBuffStat.火焰灵气)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.火焰灵气));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.火焰灵气));
        }
        if (statups.containsKey(MapleBuffStat.天使复仇)) {
            // empty if block
        }
        if (statups.containsKey(MapleBuffStat.天堂之门)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.天堂之门));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.天堂之门));
        }
        if (statups.containsKey(MapleBuffStat.伤害吸收)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.伤害吸收));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.伤害吸收));
        }
        if (statups.containsKey(MapleBuffStat.神圣保护)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.神圣保护));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.神圣保护));
        }
        if (statups.containsKey(MapleBuffStat.无敌状态)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.无敌状态));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.无敌状态));
        }
        if (statups.containsKey(MapleBuffStat.流血剧毒)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.流血剧毒));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.流血剧毒));
        }
        if (statups.containsKey(MapleBuffStat.隐形剑)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.隐形剑));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.隐形剑));
        }
        if (statups.containsKey(MapleBuffStat.不倦神酒)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.不倦神酒));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.不倦神酒));
        }
        if (statups.containsKey(MapleBuffStat.阿修罗)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.阿修罗));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.阿修罗));
        }
        if (statups.containsKey(MapleBuffStat.超能光束炮)) {
            mplew.writeInt(player.getBuffedIntValue(MapleBuffStat.超能光束炮));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.超能光束炮));
        }
        if (statups.containsKey(MapleBuffStat.混元归一)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.混元归一));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.混元归一));
        }
        if (statups.containsKey(MapleBuffStat.IgnoreMobpdpR)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.IgnoreMobpdpR));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.IgnoreMobpdpR));
        }
        if (statups.containsKey(MapleBuffStat.返回原位置)) {
            mplew.write(1);
            mplew.writeShort(player.getDiseasesValue(MapleDisease.返回原位置).skillid);
            mplew.writeShort(player.getDiseasesValue(MapleDisease.返回原位置).level);
        }
        if (statups.containsKey(MapleBuffStat.精灵的帽子)) {
            mplew.writeShort(1);
            mplew.writeShort(player.getDiseasesValue(MapleDisease.精灵帽子).skillid);
            mplew.writeShort(player.getDiseasesValue(MapleDisease.精灵帽子).level);
        }
        if (statups.containsKey(MapleBuffStat.恶魔超越)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.恶魔超越));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.恶魔超越));
        }
        if (statups.containsKey(MapleBuffStat.FireBomb)) {
            mplew.write(player.getBuffedIntValue(MapleBuffStat.FireBomb));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.FireBomb));
        }
        if (statups.containsKey(MapleBuffStat.尖兵能量)) {
            mplew.write(player.getSpecialStat().getPowerCount());
        }
        if (statups.containsKey(MapleBuffStat.飞行骑乘)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.飞行骑乘));
            mplew.writeInt(Math.abs(player.getTrueBuffSource(MapleBuffStat.飞行骑乘)));
        }
        if (statups.containsKey(MapleBuffStat.NaviFlying)) {
            mplew.writeShort(0);
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.永动引擎)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.永动引擎));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.永动引擎));
        }
        if (statups.containsKey(MapleBuffStat.元素属性)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.元素属性));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.元素属性));
        }
        if (statups.containsKey(MapleBuffStat.开天辟地)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.开天辟地));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.开天辟地));
        }
        if (statups.containsKey(MapleBuffStat.EventPointAbsorb)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.EventPointAbsorb));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.EventPointAbsorb));
        }
        if (statups.containsKey(MapleBuffStat.ECONDARY_STAT_EventAssemble)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.ECONDARY_STAT_EventAssemble));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.ECONDARY_STAT_EventAssemble));
        }
        if (statups.containsKey(MapleBuffStat.信天翁)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.属性攻击));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.属性攻击));
        }
        if (statups.containsKey(MapleBuffStat.神之子透明)) {
            mplew.writeShort(0);
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.月光转换)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.月光转换));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.月光转换));
        }
        if (statups.containsKey(MapleBuffStat.SoulMP)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.SoulMP));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.SoulMP));
        }
        if (statups.containsKey(MapleBuffStat.元素灵魂_僵直)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.元素灵魂_僵直));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.元素灵魂_僵直));
        }
        if (statups.containsKey(MapleBuffStat.日月轮转)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.日月轮转));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.日月轮转));
        }
        if (statups.containsKey(MapleBuffStat.重生契约)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.重生契约));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.重生契约));
        }
        if (statups.containsKey(MapleBuffStat.灵魂助力)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.灵魂助力));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.灵魂助力));
        }
        if (statups.containsKey(MapleBuffStat.三彩箭矢)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.三彩箭矢));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.三彩箭矢));
        }
        if (statups.containsKey(MapleBuffStat.防甲穿透)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.防甲穿透));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.防甲穿透));
        }
        if (statups.containsKey(MapleBuffStat.灵气大融合)) {
            // empty if block
        }
        // SPAWN 3
        if (statups.containsKey(MapleBuffStat.圣洁之力)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.圣洁之力));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.圣洁之力));
        }
        // SPAWN 4
        if (statups.containsKey(MapleBuffStat.神圣迅捷)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.神圣迅捷));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.神圣迅捷));
        }
        if (statups.containsKey(MapleBuffStat.ImmuneBarrier)) {
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.ImmuneBarrier)) {
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.FullSoulMP)) {
            mplew.writeInt(player.getEquippedSoulSkill());
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.神圣保护)) {
            mplew.writeBool(player.getBuffSource(MapleBuffStat.神圣保护) == 主教.神圣保护);
        }
        if (statups.containsKey(MapleBuffStat.地雷)) {
            mplew.writeInt(0);
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.招魂结界)) {
            mplew.writeInt(player.getBuffedIntValue(MapleBuffStat.招魂结界));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.招魂结界));
        }
        if (statups.containsKey(MapleBuffStat.UNK404)) {
            mplew.writeInt(player.getBuffedIntValue(MapleBuffStat.UNK404));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.UNK404));
        }
        if (statups.containsKey(MapleBuffStat.ComboTempest)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.ComboTempest));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.ComboTempest));
        }
        if (statups.containsKey(MapleBuffStat.HalfstatByDebuff)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.HalfstatByDebuff));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.HalfstatByDebuff));
        }
        if (statups.containsKey(MapleBuffStat.ComplusionSlant)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.ComplusionSlant));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.ComplusionSlant));
        }
        if (statups.containsKey(MapleBuffStat.召唤美洲豹)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.召唤美洲豹));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.召唤美洲豹));
        }
        // SPAWN 5
        if (statups.containsKey(MapleBuffStat.战法灵气)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.战法灵气));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.战法灵气));
        }
        if (statups.containsKey(MapleBuffStat.超人变形)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.超人变形));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.超人变形));
        }
        if (statups.containsKey(MapleBuffStat.爱星能量)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.爱星能量));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.爱星能量));
        }
        if (statups.containsKey(MapleBuffStat.心雷合一)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.心雷合一));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.心雷合一));
        }
        if (statups.containsKey(MapleBuffStat.子弹盛宴)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.子弹盛宴));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.子弹盛宴));
        }
        if (statups.containsKey(MapleBuffStat.UNK466)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.UNK466));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.UNK466));
        }
        if (statups.containsKey(MapleBuffStat.变换攻击)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.变换攻击));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.变换攻击));
        }
        if (statups.containsKey(MapleBuffStat.祈祷)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.祈祷));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.祈祷));
        }
        if (statups.containsKey(MapleBuffStat.黑暗闪电)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.黑暗闪电));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.黑暗闪电));
        }
        if (statups.containsKey(MapleBuffStat.战斗大师)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.战斗大师));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.战斗大师));
        }
        if (statups.containsKey(MapleBuffStat.花炎结界)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.花炎结界));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.花炎结界));
        }
        if (statups.containsKey(MapleBuffStat.KeyDownMoving)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.KeyDownMoving));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.KeyDownMoving));
        }
        if (statups.containsKey(MapleBuffStat.灵魂链接)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.灵魂链接));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.灵魂链接));
        }
        if (statups.containsKey(MapleBuffStat.心魂本能)) {
            mplew.writeInt(player.getBuffedIntValue(MapleBuffStat.心魂本能));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.心魂本能));
        }
        if (statups.containsKey(MapleBuffStat.不消耗HP)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.不消耗HP));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.不消耗HP));
        }
        if (statups.containsKey(MapleBuffStat.不消耗HP)) {
            mplew.writeInt(player.getBuffSource(MapleBuffStat.不消耗HP));
        }
        if (statups.containsKey(MapleBuffStat.UNK_MBS_437)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.UNK_MBS_437));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.UNK_MBS_437));
        }
        // SPAWN 9
        if (statups.containsKey(MapleBuffStat.激素狂飙)) {
            mplew.writeInt(player.getBuffSource(MapleBuffStat.激素狂飙));
        }
        // SPAWN 10
        if (statups.containsKey(MapleBuffStat.忍耐之盾)) {
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.UNK_MBS_450)) {
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.UNK451)) {
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.向导之箭)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.向导之箭));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.向导之箭));
        }
        if (statups.containsKey(MapleBuffStat.UNK250)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.UNK250));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.UNK250));
        }
        if (statups.containsKey(MapleBuffStat.祝福标记)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.祝福标记));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.祝福标记));
        }
        if (statups.containsKey(MapleBuffStat.精灵元素)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.精灵元素));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.精灵元素));
        }
        if (statups.containsKey(MapleBuffStat.戴米安刻印)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.戴米安刻印));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.戴米安刻印));
        }
        if (statups.containsKey(MapleBuffStat.神圣归一)) {
            mplew.writeInt(player.getBuffedIntValue(MapleBuffStat.神圣归一));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.神圣归一));
        }
        if (statups.containsKey(MapleBuffStat.神奇圆环)) {
            mplew.writeInt(player.getBuffedIntValue(MapleBuffStat.神奇圆环));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.神奇圆环));
        }
        // SPAWN 11
        if (statups.containsKey(MapleBuffStat.心魂龙卷风)) {
            mplew.writeInt(player.getBuffedIntValue(MapleBuffStat.心魂龙卷风));
        }
        if (statups.containsKey(MapleBuffStat.装备摩诃)) {
            mplew.writeInt(player.getBuffedIntValue(MapleBuffStat.装备摩诃));
        }
        if (statups.containsKey(MapleBuffStat.超压魔力)) {
            mplew.writeInt(player.getBuffedIntValue(MapleBuffStat.超压魔力));
        }
        if (statups.containsKey(MapleBuffStat.CursorSniping)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.CursorSniping));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.CursorSniping));
        }
        if (statups.containsKey(MapleBuffStat.UNK499)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.UNK499));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.UNK499));
        }
        if (statups.containsKey(MapleBuffStat.聚光灯)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.聚光灯));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.聚光灯));
        }
        if (statups.containsKey(MapleBuffStat.过载模式)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.过载模式));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.过载模式));
        }
        if (statups.containsKey(MapleBuffStat.弗里德的加护)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.弗里德的加护));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.弗里德的加护));
        }
        if (statups.containsKey(MapleBuffStat.强化祝福之锤)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.强化祝福之锤));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.强化祝福之锤));
        }
        if (statups.containsKey(MapleBuffStat.超速传动)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.超速传动));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.超速传动));
        }
        if (statups.containsKey(MapleBuffStat.次元神隐)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.次元神隐));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.次元神隐));
        }
        if (statups.containsKey(MapleBuffStat.视死如归)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.视死如归));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.视死如归));
        }
        if (statups.containsKey(MapleBuffStat.暴击强化)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.暴击强化));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.暴击强化));
        }
        if (statups.containsKey(MapleBuffStat.钢铁之躯)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.钢铁之躯));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.钢铁之躯));
        }
        if (statups.containsKey(MapleBuffStat.荣耀之翼)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.荣耀之翼));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.荣耀之翼));
        }
        if (statups.containsKey(MapleBuffStat.UNK514)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.UNK514));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.UNK514));
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.UNK515)) {
            mplew.writeInt(player.getBuffedIntValue(MapleBuffStat.UNK515));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.UNK515));
        }
        if (statups.containsKey(MapleBuffStat.和谐连接)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.和谐连接));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.和谐连接));
        }
        if (statups.containsKey(MapleBuffStat.快速充能)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.快速充能));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.快速充能));
        }
        if (statups.containsKey(MapleBuffStat.控制侵蚀)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.控制侵蚀));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.控制侵蚀));
        }
        if (statups.containsKey(MapleBuffStat.追魂手)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.追魂手));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.追魂手));
        }
        if (statups.containsKey(MapleBuffStat.UNK540)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.UNK540));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.UNK540));
        }
        if (statups.containsKey(MapleBuffStat.UNK515)) {
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.UNK530)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.UNK530));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.UNK530));
        }
        if (statups.containsKey(MapleBuffStat.守护模式变更)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.守护模式变更));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.守护模式变更));
        }
        if (statups.containsKey(MapleBuffStat.舞力全开)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.舞力全开));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.舞力全开));
        }
        if (statups.containsKey(MapleBuffStat.UNK533)) {
            mplew.writeInt(player.getBuffedIntValue(MapleBuffStat.UNK533));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.UNK533));
        }
        if (statups.containsKey(MapleBuffStat.UNK547)) {
            mplew.writeInt(player.getBuffedIntValue(MapleBuffStat.UNK547));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.UNK547));
        }
        if (statups.containsKey(MapleBuffStat.拔刀姿势)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.拔刀姿势));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.拔刀姿势));
            mplew.writeInt(-剑豪.拔刀姿势);
        }
        if (statups.containsKey(MapleBuffStat.拔刀术加成)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.拔刀术加成));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.拔刀术加成));
        }
        if (statups.containsKey(MapleBuffStat.UNK539)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.UNK539));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.UNK539));
        }
        if (statups.containsKey(MapleBuffStat.武神招来_攻击)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.武神招来_攻击));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.武神招来_攻击));
        }
        if (statups.containsKey(MapleBuffStat.武神招来_MAXHP)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.武神招来_MAXHP));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.武神招来_MAXHP));
        }
        if (statups.containsKey(MapleBuffStat.武神招来_MAXMP)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.武神招来_MAXMP));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.武神招来_MAXMP));
        }
        if (statups.containsKey(MapleBuffStat.一闪)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.一闪));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.一闪));
        }
        if (statups.containsKey(MapleBuffStat.花炎结界)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.花炎结界));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.花炎结界));
        }
        if (statups.containsKey(MapleBuffStat.UNK547)) {
            mplew.writeInt(player.getBuffedIntValue(MapleBuffStat.UNK547));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.UNK547));
        }
        if (statups.containsKey(MapleBuffStat.稳如泰山)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.稳如泰山));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.稳如泰山));
        }
        if (statups.containsKey(MapleBuffStat.UNK_MBS_437)) {
            mplew.writeInt(player.getBuffedIntValue(MapleBuffStat.UNK_MBS_437));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.UNK_MBS_437));
        }
        if (statups.containsKey(MapleBuffStat.结界破魔)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.结界破魔));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.结界破魔));
        }
        if (statups.containsKey(MapleBuffStat.厚积薄发)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.厚积薄发));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.厚积薄发));
        }
        if (statups.containsKey(MapleBuffStat.晓月流基本技能)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.晓月流基本技能));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.晓月流基本技能));
        }
        if (statups.containsKey(MapleBuffStat.水枪阵营)) {
            mplew.writeInt(player.getBuffSource(MapleBuffStat.水枪阵营));
        }
        if (statups.containsKey(MapleBuffStat.水枪军阶)) {
            mplew.writeInt(player.getBuffSource(MapleBuffStat.水枪军阶));
        }
        if (statups.containsKey(MapleBuffStat.水枪效果)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.水枪效果));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.水枪效果));
        }
        if (statups.containsKey(MapleBuffStat.UNK555)) {
            mplew.writeInt(player.getBuffSource(MapleBuffStat.UNK555));
        }
        if (statups.containsKey(MapleBuffStat.ReduceMana)) {
            mplew.writeInt(player.getBuffSource(MapleBuffStat.ReduceMana));
        }
        if (statups.containsKey(MapleBuffStat.爆裂箭)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.爆裂箭));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.爆裂箭));
        }
        if (statups.containsKey(MapleBuffStat.UNK567)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.UNK567));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.UNK567));
        }
        mplew.write(0);
        mplew.write(0);
        mplew.write(JobConstants.is魂骑士(player.getJob()) ? 5 : 0);
        mplew.writeInt(0);
        int n4 = player.getBuffSource(MapleBuffStat.能量获得);
        mplew.writeInt(player.getSpecialStat().isEnergyFull() ? n4 : 0);
        if (statups.containsKey(MapleBuffStat.月光转换)) {
            mplew.write(player.getBuffedValue(MapleBuffStat.月光转换) != null ? 1 : 0);
        }
        if (statups.containsKey(MapleBuffStat.圣洁之力)) {
            mplew.write(0);
        }
        if (statups.containsKey(MapleBuffStat.神圣迅捷)) {
            mplew.write(0);
        }
        if (statups.containsKey(MapleBuffStat.战法灵气)) {
            mplew.write(player.getBuffedValue(MapleBuffStat.战法灵气) != null ? 1 : 0);
        }
        // SPAWN 6
        if (statups.containsKey(MapleBuffStat.结合灵气)) {
            mplew.writeInt(0);
            mplew.writeInt(0);
            mplew.writeInt(0);
        }
        // SPAWN 7
        if (statups.containsKey(MapleBuffStat.BattlePvP_LangE_Protection)) {
            mplew.writeInt(0);
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.灵魂链接)) {
            mplew.writeInt(player.getBuffStatValueHolder(MapleBuffStat.灵魂链接).getCid() == player.getId() ? statups.get(MapleBuffStat.灵魂链接) : 0);
            mplew.writeBool(player.getBuffStatValueHolder(MapleBuffStat.灵魂链接).getCid() == player.getId() && statups.get(MapleBuffStat.灵魂链接) <= 1);
            mplew.writeInt(player.getBuffStatValueHolder(MapleBuffStat.灵魂链接).getCid());
            mplew.writeInt(statups.get(MapleBuffStat.灵魂链接) > 1 ? (int) player.getBuffStatValueHolder(MapleBuffStat.灵魂链接).getEffect().getLevel() : 0);
        }
        if (statups.containsKey(MapleBuffStat.激素狂飙)) {
            mplew.write(1);
        }
        if (statups.containsKey(MapleBuffStat.戴米安刻印)) {
            mplew.writeInt(player.getBuffedIntValue(MapleBuffStat.戴米安刻印));
        }
        if (statups.containsKey(MapleBuffStat.神圣归一)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.神圣归一));
        }
        if (statups.containsKey(MapleBuffStat.SpinesOfShadow)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.SpinesOfShadow));
        }
        if (statups.containsKey(MapleBuffStat.UNK404)) {
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.UNK404));
        }
        if (statups.containsKey(MapleBuffStat.神奇圆环)) {
            mplew.writeInt(player.getBuffedIntValue(MapleBuffStat.神奇圆环));
            mplew.writeInt(0);
            mplew.writeInt(0);
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.VampDeath)) {
            mplew.writeInt(player.getBuffedIntValue(MapleBuffStat.VampDeath));
        }
        if (statups.containsKey(MapleBuffStat.荣耀之翼)) {
            mplew.writeInt(0);
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.祝福标记)) {
            mplew.writeInt(0);
            mplew.writeInt(0);
        }
        // SPAWN 12
        if (statups.containsKey(MapleBuffStat.UNK521)) {
            mplew.writeInt(0);
            mplew.writeInt(0);
            mplew.writeInt(0);
        }
        PacketHelper.write剑刃之壁(mplew, player, player.getBuffSource(MapleBuffStat.剑刃之壁));
        // SPAWN 12
        rand = isChrinfo ? Randomizer.nextInt() : 1;
        if (statups.containsKey(MapleBuffStat.能量获得)) {
            mplew.writeLong(Math.min(player.getEnergyCount(), 10000));
            mplew.write(1);
            mplew.writeInt(rand);
        }
        // SPAWN 13
        if (statups.containsKey(MapleBuffStat.疾驰速度)) {
            mplew.writeZeroBytes(8);
            mplew.write(1);
            mplew.writeInt(rand);
            mplew.writeShort(0);
        }
        // SPAWN 14
        if (statups.containsKey(MapleBuffStat.疾驰跳跃)) {
            mplew.writeZeroBytes(8);
            mplew.write(1);
            mplew.writeInt(rand);
            mplew.writeShort(0);
        }
        // SPAWN 15
        if (statups.containsKey(MapleBuffStat.骑兽技能)) {
            sourceid = player.getBuffSource(MapleBuffStat.骑兽技能);
            if (sourceid > 0) {
                MaplePacketCreator.addMountId(mplew, player, sourceid);
                mplew.writeInt(sourceid);
            } else {
                mplew.writeLong(0);
            }
            mplew.write(1);
            mplew.writeInt(rand);
        }
        // SPAWN 16
        if (statups.containsKey(MapleBuffStat.极速领域)) {
            mplew.writeZeroBytes(8);
            mplew.write(1);
            mplew.writeInt(rand);
        }
        // SPAWN 17
        if (statups.containsKey(MapleBuffStat.导航辅助)) {
            mplew.write(0);
            mplew.writeInt(Randomizer.nextInt());
            mplew.writeZeroBytes(10);
            mplew.write(1);
            mplew.writeInt(rand);
        }
        // SPAWN 18
        if (statups.containsKey(MapleBuffStat.Undead)) {
            mplew.writeZeroBytes(16);
            mplew.write(1);
            mplew.writeInt(rand);
        }
        // SPAWN 19
        if (statups.containsKey(MapleBuffStat.RideVehicleExpire)) {
            mplew.writeInt(player.getBuffedIntValue(MapleBuffStat.RideVehicleExpire));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.RideVehicleExpire));
            mplew.writeShort(player.getBuffedIntValue(MapleBuffStat.RideVehicleExpire) > 0 ? 10 : 0);
            mplew.write(1);
            mplew.writeInt(rand);
        }
        // SPAWN 20
        if (statups.containsKey(MapleBuffStat.COUNT_PLUS1)) {
            mplew.writeInt(player.getBuffedIntValue(MapleBuffStat.COUNT_PLUS1));
            mplew.writeInt(player.getBuffSource(MapleBuffStat.COUNT_PLUS1));
            mplew.writeShort(0);
            mplew.write(1);
            mplew.writeInt(rand);
        }
        // SPAWN 1
        if (statups.containsKey(MapleBuffStat.UNK50)) {
            mplew.writeInt(0);
            mplew.writeShort(0);
        }
        if (statups.containsKey(MapleBuffStat.UNK499)) {
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.KeyDownMoving)) {
            mplew.writeInt(0);
        }
        if (statups.containsKey(MapleBuffStat.飞行骑乘)) {
            sourceid = player.getBuffSource(MapleBuffStat.骑兽技能);
            if (sourceid > 0) {
                MaplePacketCreator.addMountId(mplew, player, sourceid);
            } else {
                mplew.writeInt(0);
            }
        }
        if (statups.containsKey(MapleBuffStat.UNK540)) {
            mplew.writeInt(0);
        }
    }

    /*
     * 取消BUFF状态
     */
    public static byte[] cancelBuff(List<MapleBuffStat> statups, MapleCharacter chr) {
        log.trace("调用");
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.CANCEL_BUFF.getValue());
        writeBuffMask(mplew, statups);
        boolean hasDisease = false;
        for (MapleBuffStat mask : statups) {
            if (!hasDisease) {
                hasDisease = MapleDisease.isDisease(mask);
            }
            if (mask.canStack() && !SkillConstants.isWriteNeedPointValue(mask)) {
                List<MapleBuffStatValueHolder> buffs = chr.getIndieBuffStatValueHolder(mask);
                mplew.writeInt(buffs != null ? buffs.size() : 0); //这个地方是有多少个重复的特殊BUFF 是1个循环 取消后还剩余几个这个效果 还要继续写剩余效果的属性
                if (buffs == null || buffs.size() <= 0) {
                    continue;
                }
                for (MapleBuffStatValueHolder info : buffs) {
                    mplew.writeInt(info.getEffectID());
                    mplew.writeInt(info.getValue());
                    mplew.writeIntAsLong(info.getStartTime());
                    mplew.writeInt(0); //V.114新增
                    mplew.writeInt(info.getLocalDuration());
                    mplew.writeInt(0);
                }
            }
        }
        for (MapleBuffStat mask : statups) {
            if (SkillConstants.isWriteBuffByteData(mask)) {
                mplew.write(0);
            }
        }
        if (statups.contains(MapleBuffStat.月光转换)) {
            mplew.write(1);
        }
        if (statups.contains(MapleBuffStat.RideVehicleExpire)) {
            mplew.write(1);
        }
        if (statups.contains(MapleBuffStat.骑兽技能)) {
            mplew.write(3);
        } else if (hasDisease) {
            mplew.write(3);
            mplew.write(0);
            mplew.write(1);
        }

        return mplew.getPacket();
    }

    /*
     * 取消BUFF状态
     */
    public static byte[] cancelBuff(MapleBuffStat buffstat) {
        log.trace("调用");
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.CANCEL_BUFF.getValue());
        writeBuffMask(mplew, Collections.singletonList(buffstat));
        if (buffstat.canStack()) {
            mplew.writeInt(0);
        }

        return mplew.getPacket();
    }

    /*
     * 取消负面BUFF状态
     */
    public static byte[] cancelDebuff(MapleDisease mask) {
        log.trace("调用");
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.CANCEL_BUFF.getValue());
        writeBuffMask(mplew, Collections.singletonList(mask));
        mplew.write(3);
        mplew.write(0);
        mplew.write(1);

        return mplew.getPacket();
    }

    //召唤炮台
    public static byte[] spawnArrowsTurret(MapleArrowsTurret summon) {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.SPAWN_ARROWS_TURRET.getValue());
        mplew.writeInt(summon.getObjectId());
        mplew.writeInt(1);
        mplew.writeInt(summon.getOwnerId());
        mplew.writeInt(0);
        mplew.writeInt(summon.getPosition().x);
        mplew.writeInt(summon.getPosition().y);
        mplew.write(summon.getSide());

        return mplew.getPacket();
    }

    public static byte[] isArrowsTurretAction(MapleArrowsTurret summon, boolean attack) {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(attack ? SendPacketOpcode.ARROWS_TURRET_ACTION.getValue() : SendPacketOpcode.SPAWN_ARROWS_TURRET.getValue());
        mplew.writeInt(summon.getObjectId());
        mplew.writeInt(attack ? 0 : 1);
        if (!attack) {
            mplew.writeInt(summon.getOwnerId());
            mplew.writeInt(0);
            mplew.writeInt(summon.getPosition().x);
            mplew.writeInt(summon.getPosition().y);
            mplew.write(summon.getSide());
        }

        return mplew.getPacket();
    }

    //炮台开始攻击
    public static byte[] ArrowsTurretAction(MapleArrowsTurret summon) {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.ARROWS_TURRET_ACTION.getValue());
        mplew.writeInt(summon.getObjectId());
        mplew.writeInt(0);

        return mplew.getPacket();
    }

    //删除炮台
    public static byte[] cancelArrowsTurret(MapleArrowsTurret summon) {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.CANCEL_ARROWS_TURRET.getValue());
        mplew.writeInt(1);
        mplew.writeInt(summon.getObjectId());

        return mplew.getPacket();
    }

    //箭矢炮盘效果(炮台状态)
    public static byte[] CannonPlateEffectFort(MapleCharacter from, int skillId, Point pos, int nuk, short dir, int Temporary, int Temporary1, int Temporary2, int DirPos1, int DirPos2) {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.CANNON_PLATE.getValue());
        mplew.writeShort(4);
        mplew.writeInt(from.getId());
        mplew.writeInt(from.getMapId());
        mplew.write(1);
        mplew.writeShort(0);
        mplew.writePos(pos);//位置
        mplew.writeInt(nuk);//技能时间?
        mplew.writeShort(Temporary);
        mplew.writeShort(Temporary1);
        mplew.writeShort(Temporary2);//
        mplew.writeInt(skillId);//技能ID
        mplew.write((byte) dir);//炮台的面向
        mplew.writeInt((dir == 1) ? -DirPos1 : DirPos1);//射箭的方向,X
        mplew.writeInt(DirPos2);//射箭的方向,Y

        return mplew.getPacket();
    }

    public static byte[] switchLuckyMoney(boolean on) {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.SWITCH_LUCKYMONEY.getValue());
        mplew.writeBool(on);
        return mplew.getPacket();
    }

    public static <E extends Buffstat> void writeBuffMask(MaplePacketLittleEndianWriter mplew, Map<E, Integer> statups) {
        writeBuffMask(mplew, statups.keySet());
    }

    public static <E extends Buffstat> void writeBuffMask(MaplePacketLittleEndianWriter mplew, Collection<E> statups) {
        int[] mask = new int[GameConstants.MAX_BUFFSTAT];
        for (E statup : statups) {
            mask[statup.getPosition()] |= statup.getValue();
        }
        for (int aMask : mask) {
            mplew.writeInt(aMask);
        }
    }

    public static byte[] showFirewall(int oid, int skillid, Rectangle rectangle, int unk_value) {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.SHOW_FIREWALL.getValue());
        mplew.writeInt(oid);
        mplew.writeInt(skillid);
        mplew.writeInt(50 * Randomizer.rand(7, 9));
        mplew.writeInt(rectangle.x);
        mplew.writeInt(-rectangle.y);
        mplew.writeInt(rectangle.x + rectangle.width);
        mplew.writeInt(rectangle.y + rectangle.height - 22);

        return mplew.getPacket();
    }

    public static byte[] showFirewall(int oid, Rectangle rectangle) {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.SHOW_FIREWALL.getValue());
        mplew.writeInt(1);
        mplew.writeInt(155121006);
        mplew.writeInt(0);
        mplew.writeRect(rectangle);

        return mplew.getPacket();
    }

    public static byte[] giveGodBuff(int sourceid, int bufflength) {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.GIVE_BUFF.getValue());
        writeBuffMask(mplew, Collections.singletonList(MapleBuffStat.无敌状态));
        mplew.writeShort(1);
        mplew.writeInt(sourceid);
        mplew.writeInt(bufflength);
        mplew.writeZeroBytes(22);

        return mplew.getPacket();
    }

    public static byte[] giveElementalShock(int n2, int n3) {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();

        mplew.writeShort(SendPacketOpcode.GIVE_BUFF.getValue());
        writeBuffMask(mplew, Collections.singletonList(MapleBuffStat.元素冲击));
        mplew.writeShort(2 * n2);
        mplew.writeInt(n3);
        mplew.writeInt(2100000000);
        mplew.writeInt(0);
        mplew.write(13);
        mplew.write(n2);
        mplew.writeShort(n2 * 8);
        mplew.write(2 * n2);
        mplew.write(2 * n2);
        mplew.writeZeroBytes(17);

        return mplew.getPacket();
    }

}
